package org.jetlinks.pro.datasource.rdb;

import org.hswebframework.ezorm.rdb.operator.DatabaseOperator;
import org.jetlinks.pro.datasource.Command;
import org.jetlinks.pro.datasource.DataSource;
import org.jetlinks.pro.datasource.DataSourceType;

import javax.annotation.Nonnull;


public interface RDBDataSource extends DataSource {

    RDBDataSourceProperties getConfig();

    RDBDataSourceProperties copyConfig();

    DatabaseOperator operator();

    /**
     * @param command 指令
     * @param <R>     指令结果
     * @see org.jetlinks.pro.datasource.rdb.command.GetTable
     * @see org.jetlinks.pro.datasource.rdb.command.GetTables
     * @see org.jetlinks.pro.datasource.rdb.command.CreateOrAlterTable
     * @see org.jetlinks.pro.datasource.rdb.command.DropColumn
     * @see org.jetlinks.pro.datasource.rdb.command.Upsert
     */
    @Nonnull
    @Override
    <R> R execute(@Nonnull Command<R> command);

    @Override
    default DataSourceType getType() {
        return RDBDataSourceType.rdb;
    }
}
